//app.js
App({
  globalData: {
    userInfo: null,
    AppName: "拾间记录本",
    openid: "",
    appid: 'wx511a67ed3b53c79a'
  },
  onLaunch: function () {
    //从缓存中获取openId
    this.globalData.openid = wx.getStorageSync('openId') || ''

    // 获取系统状态栏信息
    wx.getSystemInfo({
      success: e => {
        this.globalData.StatusBar = e.statusBarHeight;
        let capsule = wx.getMenuButtonBoundingClientRect();
        if (capsule) {
          this.globalData.Custom = capsule;
          this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
        } else {
          this.globalData.CustomBar = e.statusBarHeight + 50;
        }
      }
    })

    wx.getSetting({
      success: res => {
        if (res.authSetting['scope.userInfo']) {
          if (wx.getStorageSync('openId')) {
            wx.getUserInfo({
              lang: "zh_CN",
              success: res => {
                this.globalData.userInfo = res.userInfo
                wx.setStorageSync('userInfo', res.userInfo)
                if (this.userInfoReadyCallback) {
                  this.userInfoReadyCallback(res)
                }
              }
            })
          }
        }
      }
    })
  }
})